package com.example.tcisdk_jartest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

import com.tci.sdk.OnSdkResponseListener;
import com.tci.sdk.TCIOA;

public class MainActivity extends Activity {

    String token;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // TCIOA tciOA = new TCIOA();
        // tciOA.init(MainActivity.this, "1", "830edfa157830d93c5dfa70d82aa2a30", "testChannel");
        // tciOA.login(MainActivity.this, new OnSdkResponseListener() {

        //     @Override
        //     public void onSdkResponse(String jsonResult) {
        //         ULog.d(jsonResult);
        //         Toast.makeText(MainActivity.this, jsonResult, Toast.LENGTH_SHORT).show();
        //     }
        // });

        findViewById(R.id.button1).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                TCIOA tciOA = TCIOA.getInstance();
                tciOA.init(MainActivity.this, "1", "830edfa157830d93c5dfa70d82aa2a30", "testChannel");
                tciOA.login(MainActivity.this, new OnSdkResponseListener() {

                    @Override
                    public void onSdkResponse(String jsonResult) {
                        ULog.d(jsonResult);
                        Toast.makeText(MainActivity.this, jsonResult, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });

        findViewById(R.id.button3).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                Bundle params = new Bundle();
                params.putInt(Keys.KEY_SCREEN_ORIENTATION, 1);
                params.putString("playerid", "18918189802");
                params.putString(Keys.KEY_RETURN_TOKEN, "12b838b0706d4a3fab34c04e50ba4490");
                params.putString(Keys.KEY_PAY_BODY, "测试商品的详细描述");
                params.putString(Keys.KEY_PAY_SUBJECT, "测试商品");
                params.putString(Keys.KEY_HTTP_ORDERID, "10000789");
                params.putInt(Keys.KEY_PAY_TOTAL_FEE, 1);

                TCIOA.getInstance().pay(MainActivity.this, params, new OnSdkResponseListener() {
                    @Override
                    public void onSdkResponse(String jsonResult) {
                        // TODO Auto-generated method stub
                        ULog.d(jsonResult);
                        Toast.makeText(MainActivity.this, jsonResult, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });

    }

}
